package com.example.blogtest;


import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

import java.util.concurrent.TimeUnit;

//测试登录页面
public class LoginTest {

    @Test
    //测试菜单栏
    public void menuGround() {
        //1. 创建浏览器驱动
        WebDriver webDriver = new ChromeDriver();
        //2. 指定页面
        webDriver.get("http://127.0.0.1:8080/blog_signIn.html");
        //隐式等待
        webDriver.manage().timeouts().implicitlyWait(5, TimeUnit.MILLISECONDS);
        //3. 测试菜单栏和菜单栏中的元素
        WebElement element1 = webDriver.findElement(By.cssSelector("body > div.nav"));
        WebElement element2 = webDriver.findElement(By.cssSelector("body > div.nav > img"));
        WebElement element3 = webDriver.findElement(By.cssSelector("body > div.nav > span"));
        WebElement element4 = webDriver.findElement(By.cssSelector("body > div.nav > a:nth-child(4)"));
        WebElement element5 = webDriver.findElement(By.cssSelector("body > div.nav > a:nth-child(5)"));
        if(element1 == null || element2 == null || element3 == null || element4 == null || element5 == null) {
            System.out.println("菜单栏测试失败");
        }else {
            System.out.println("菜单栏测试成功");
        }
    }

    //测试登录框
    public void loginInput() {

    }

}
